import { Controller, Get, Query } from "@nestjs/common";
import { FranceService } from "./france.service";
import * as TLSSigAPIv2 from "tls-sig-api-v2"

@Controller("activity")
export class FranceController {
  constructor(
    private readonly franceService: FranceService
  ) { }

  @Get("/france_activity_2024/api/get-data")
  filter(@Query() query: any) {
    return this.franceService.filterProxy(query);
  }

  @Get("/france_activity_2024/api/get-article")
  getArticle(@Query() query: any) {
    return this.franceService.getArticle(query);
  }

  @Get("dx")
  dx() {
    const uid = "tidAfffc8cbtidB_1"
    const app_id = 1400323124
    var api = new TLSSigAPIv2.Api(app_id, "538a23686e40b1bb5ef2e5f3de6b8f2575f5f496020da74da9285d583be7cbe3");
    var sig = api.genSig("tidAfffc8cbtidB_1", Math.floor(Date.now() / 1000) + 86400*180);
    console.log(sig);
    const res = `sdkappid=${app_id}&userid=${uid}&usersig=${sig}`
    return {
      sig,
      res,
      length: res.length,
    }
  }
}